package org.dralee.springsecurity.configs;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author jackielee
 * @version 1.0
 * @description WebResourceAdapter
 * @date 2021/3/29
 **/
@Configuration
public class WebResourceAdapter implements WebMvcConfigurer {
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry
//                .addResourceHandler("/**")
//                .addResourceLocations("classpath:/META-INF/resources/")
//                .addResourceLocations("classpath:/resources/")
//                .addResourceLocations("classpath:/static/")
//                .addResourceLocations("classpath:/templates/")
//                .addResourceLocations("classpath:/public/")
//                .addResourceLocations("classpath:/assets/**")
//                .addResourceLocations("classpath:/META-INF/spring-boot-admin-server-ui/")
//                .addResourceLocations("classpath:/META-INF/spring-boot-admin-server-ui/extensions/");
//    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/api/**").allowedOrigins("*").allowedMethods("*").allowCredentials(true).maxAge(3600);
    }
}
